<?php
global $SMARTY,$DBobject,$CONFIG;
//主标题查询
$sql = "SELECT * FROM tbl_news_title WHERE deleted IS NULL ORDER BY modified DESC";
$tabs = $DBobject->executeSQL($sql);
//根据主标题查询文章
$array = [];
foreach ($tabs as $key=>$re) {
    $news_title_id = $re['id'];
    $sql = "SELECT * FROM tbl_news_management  WHERE deleted IS NULL AND publish = '1' AND news_title_id = $news_title_id ORDER BY modified DESC LIMIT 0,6 ";
    $articleInfo = $DBobject->executeSQL($sql);
    //剔除空标签
    if(empty(unclean($articleInfo))){
        unset($tabs[$key]);
        continue;
    }
    $array[$news_title_id]=unclean($articleInfo);
}

$result = array();
$sql = "SELECT COUNT(location_id) as cnt_locations FROM tbl_location WHERE location_deleted IS NULL AND location_published = 1 AND location_listing_id = 9";
if($res = $DBobject->wrappedSql($sql)){
	$SMARTY->assign('cnt_locations',$res[0]['cnt_locations']);
}
$SMARTY->assign("tabs", unclean($tabs));
$SMARTY->assign("articleInfo", $array);


